package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.ymatou.iapi.dguser.parameter.CheckwxbindBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.CheckwxbindCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
/**
*是否绑定过微信Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Checkwxbind{
	private static CheckwxbindBean checkwxbindBean;
	private static CheckwxbindCall checkwxbindCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("是否绑定过微信Test");
	}

	@Before
	public void caseUp() {
		checkwxbindBean=new CheckwxbindBean();
		checkwxbindCall=new CheckwxbindCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkwxbindCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checkwxbind_001() {
		Logger.start(true,"有绑定信息，成功");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			JsonArray dgUserBindInfo = DGUserCallService.getDGUserBindInfo(user);
			Logger.verifyEquals(1, dgUserBindInfo.size(), "有绑定信息");
			checkwxbindBean.setUserId(user);
			checkwxbindCall.setData(checkwxbindBean);
			checkwxbindCall.callService();
			Logger.verifyEquals("true", checkwxbindCall.getString("success"), "有绑定信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checkwxbind_002() {
		Logger.start(true,"没有绑定信息");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			DGUserCallService.unWxBind(user);
			checkwxbindBean.setUserId(user);
			checkwxbindCall.setData(checkwxbindBean);
			checkwxbindCall.callService();			
			
			Logger.verifyEquals("false", checkwxbindCall.getString("success"), "有绑定信息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checkwxbind_003() {
		Logger.start(true,"userId错误");
		try {
			checkwxbindBean.setUserId(1112233);
			checkwxbindCall.setData(checkwxbindBean);
			checkwxbindCall.callService();			
			Logger.verifyEquals("false", checkwxbindCall.getString("success"), "没有绑定信息");
			Logger.verifyEquals("200", checkwxbindCall.getString("status"), "code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
}